<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Vue猜数字练习</title>
</head>
<body>
<div>
    <input type="text" v-model="num" placeholder="请输入0-100之间的整数">
    <input type="button" value="猜一猜" @click="f()">
    <h1>结果:{{info}}</h1>
</div>
<script src="../js/vue.js"></script>
<script>
    let x = parseInt(Math.random() * 101);
    let v = new Vue({
        el: "div",
        data: {
            info: "",
            num:""
        },
        methods: {
            f() {
                if (x > v.num) {
                    v.info = "猜小了,重新来!";
                } else if (x < v.num) {
                    v.info = "猜大了,重新来!";
                } else {
                    v.info = "猜对了!";
                }
            }
        }
    })
</script>
</body>
</html>